<?php
$cheaper = $_GET['cheaper'];
$chep2 = $_GET['chep2'];
?>
<link href="/ast/layui/css/layui.css" rel="stylesheet">
<script src="/ast/layui/layui.js"></script>
            <div class="demo-login-container">
              <div class="layui-form-item">
                <div class="layui-input-wrap">
                <textarea id="booktalk" style="height: 450px;font-size:1.25em" lay-verify="required" placeholder="" lay-reqtext="" autocomplete="off" class="layui-textarea" lay-affix="clear">
<?php
$fileco = $_SERVER['DOCUMENT_ROOT'].'/'.$cheaper.'/'.$chep2.'.txt';
$content = file_get_contents($fileco);
echo $content;
?></textarea>
                </div>
              </div>
              <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" id='button-add'  lay-submit lay-filter="addcard">修改</button>
              </div>
             
            </div>
<script language="javascript" type="text/javascript">
    if (window.self == window.top) {
        alert("暂无通行证");
        location.href = "./";
    }
</script>
<script>
    var allpath = "<?php echo $fileco ?>";
    function saveretu(){
        var newcon = document.getElementById('booktalk').value;
        fetch('ht/update.php',{
    method: 'POST',
            headers: {
                'Content-Type': 'application/json; charset=utf-8'
            },
            body: JSON.stringify({
                url: allpath,
                content: newcon
            })
        }).then(response => response.json())
        .then(data => {
        if(data.code === 200){
            layer.msg(data.msg, {icon: 6});
        }else{
            layer.msg(data.msg, {icon: 5});
        }
        setTimeout(function(){
            window.parent.location.reload();
        }, 1000);
    })
    }
    document.getElementById('button-add').addEventListener("click",function(){
        saveretu();
    })
</script>